#include <stdio.h>
#include "stack.h"

int main() {
    int i = 0;
    _stack_t my_stack;

    stack_init(&my_stack, 5);
    printf("入栈顺序\n");
    for(i = 0; i < 5; i++){
        printf("%d ", i + 1);
        stack_push(&my_stack, i + 1);
    }
    printf("\n");
    printf("出栈顺序\n");
    for(i = 0; i < 5; i++){
        printf("%d ", stack_pop(&my_stack));
    }
    printf("\n\n");
    printf("优化出栈操作\n");
    printf("入栈顺序\n");
    for(i = 0; i < 5; i++){
        printf("%d ", i + 1);
        stack_push(&my_stack, i + 1);
    }
    printf("\n");
    printf("出栈顺序\n");
    for(i = 0; i < 5; i++){
        printf("%d ", stack_pop2(&my_stack));
    }
    printf("\n");

    stack_destroy(&my_stack);

    return 0;
}
